<?php

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Log;

class GiveUserScoreNotice implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    /**
     * @var
     */
    private $score;

    /**
     * @var
     */
    private $user;

    /**
     * Create a new job instance.
     *
     * @param $score
     * @param $user
     * @internal param $message
     */
    public function __construct($score, $user)
    {
        $this->score = $score;
        $this->user = $user;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        $message = "恭喜你，你的积分账户增加了{$this->score}个积分，快去使用吧";
        Log::debug('积分账户变动通知', [$this->user->name, $message]);
    }
}
